import React, { Component } from 'react'
import { withRouter } from 'react-router-dom'
//导入antd的导航栏组件
import { NavBar } from 'antd-mobile'
//导入PropTypes 进行类型检查
import PropTypes from 'prop-types'

import style from './index.module.css'
class NavHeader extends Component {
  render() {
    const { className, rightContent } = this.props
    return (
      <NavBar
        className={[style.navBar, className || ''].join(' ')}
        mode="light"
        icon={<i className="iconfont icon-back" />}
        onLeftClick={() => this.props.history.go(-1)}
        rightContent={rightContent}
      >
        {this.props.title}
      </NavBar>
    )
  }
}
NavHeader.propTypes = {
  title: PropTypes.string.isRequired,
  onLeftClick: PropTypes.func,
  className: PropTypes.string,
  rightContent: PropTypes.array,
}

export default withRouter(NavHeader)
